<template>
	<view class="community">
		<view class="head_bg" style="height: 60rpx;"></view>
		<view class="big_box" style="top: -30rpx;padding-top: 20rpx;">
			<view v-if="list.length>0" class="equ_list" v-for="(info,index) in list" :key="index">
				<view class="sell_title">
					<view class="sell_title_left">
						<view class="sell_name">{{info.residential_quarters_name}}</view>
						<view class="sell_address">{{info.residential_quarters_address}}</view>
					</view>
					<view class="sell_title_right">
						<view class="sell_money">结算金额：{{info.settlement_amount}}元</view>
						<view class="sell_address">{{info.settlement_time}}</view>
					</view>
				</view>
				<view class="equ_list_inner2">
					<view class="equ_list_inner_text2">订单数：{{info.order_num}}单</view>
					<view class="equ_list_inner_text3"></view>
					<view class="equ_list_inner_text2">订单收入：{{info.order_income}}元</view>
					<view class="equ_list_inner_text3">分成模式：
					<text v-if="info.sharing_model==1">毛利</text>
					<text v-if="info.sharing_model==2">纯利</text>
					</view>
					<view class="equ_list_inner_text2">套餐收入：{{info.set_meal_income}}元</view>
					<view class="equ_list_inner_text3">分成比例：{{info.sharing_ratio}}% </view>
					<view class="equ_list_inner_text2">电量：{{info.power_consumption}}度</view>
					<view class="equ_list_inner_text3">电费：{{info.order_electricity_fees}}元</view>
				</view>
			</view>
			<view style="height:100rpx;"></view>
			<view v-if="list.length==0" class="margin-top-lg text-center">
				<image src='../../../common/img/no_data.png' style="width:275rpx;height:312rpx;"></image>
			</view>
			<view v-if="list.length>0" class="text-black text-df text-center bg-white padding-sm padding-left-lg be-gray">
				{{loadingTxt}} 共({{list.length}}条记录)
			</view>
		</view>
	</view>
</template>

<script>
	let page=1,timer=null
	export default {
		data() {
			return {
				list:[],
				loadingTxt:'加载更多',
			}
		},
		onShow() {
			page=1;
			this.getlist();
		},
		methods: {
			getlist(){
				let that=this;
				that.http.tokenreq({
					url: 'agent/v1/settlement',
					data:{
						'pageindex':page
					}
				}).then((res) => {
					let e=res.data;
					console.log(e)
					if(e.code==0 && e.success){
						let list=e.rows;
						that.list=list;
						page++;
					}else{
						uni.showModal({
							content:e.message,
							showCancel:false,
						})
					}
				})
			},
			getmorelist(){
				this.loadingTxt='加载中'
				let that=this;
				that.http.tokenreq({
					url: 'agent/v1/settlement',
					data:{
						'pageindex':page
					}
				}).then((res) => {
					uni.hideLoading();
					let e=res.data;
					if(e.code==0 && e.success){
						if(e.rows.length==0){
							that.loadingTxt="已经加载全部";
							return;
						}
						that.list=that.list.concat(e.rows);
						page++
					}else{
						uni.showModal({
							content:e.message,
							showCancel:false,
						})
					}
				})
			},
			onReachBottom() {
				//阻止重复加载
				if(timer !== null){
					clearTimeout(timer)
				}
				timer=setTimeout(()=>this.getmorelist(),500)
				// this.getMoreNews()
			}
		}
	}
</script>
